//
//  NSComparisonPredicateEnums.swift
//  Documentation
//
//  Created by Toj on 11/14/23.
//

import Foundation

extension NSComparisonPredicate {
    
    public struct Options : OptionSet, @unchecked Sendable {
        
        public init(rawValue: UInt)
        
        /// 大小写不敏感 相当于"left LIKE[c] 'test'" 中的[c]/
        public static var caseInsensitive: NSComparisonPredicate.Options { get }
        
        /// 发音不敏感 相当于"left LIKE[d] 'test'" 中的[d]
        public static var diacriticInsensitive: NSComparisonPredicate.Options { get }
        
        /// 表示要比较的字符串已经过预处理;
        /// 这取代了其他选项, 旨在作为性能优化选项
        @available(iOS 4.0, *)
        public static var normalized: NSComparisonPredicate.Options { get }
    }
    
    
    // Describes how the operator is modified: can be direct, ALL, or ANY
    public enum Modifier : UInt, @unchecked Sendable {
        
        /// 直接进行比较
        case direct = 0 // Do a direct comparison
        /// 用于评估对象为NSArray、NSSet, 当对象的全部元素都符合表达式, 才算通过
        case all = 1 // ALL toMany.x = y
        /// 用于评估对象为NSArray、NSSet, 当对象的元素至少有一个符合表达式, 就算通过
        case any = 2 // ANY toMany.x = y
    }
    
    public enum Operator : UInt, @unchecked Sendable {
        
        /// 小于(即左表达式小于右表达式)
        case lessThan = 0 // compare: returns NSOrderedAscending
        /// 小于或等于
        case lessThanOrEqualTo = 1 // compare: returns NSOrderedAscending || NSOrderedSame
        // 大于
        case greaterThan = 2 // compare: returns NSOrderedDescending
        /// 大于或等于
        case greaterThanOrEqualTo = 3 // compare: returns NSOrderedDescending || NSOrderedSame
        /// 等于
        case equalTo = 4 // isEqual: returns true
        /// 不等于
        case notEqualTo = 5 // isEqual: returns false
        /// 正则 右表达式为正则表达式
        case matches = 6
        /// like匹配, 相当于=, 但可以使用通配符?和*
        case like = 7
        /// 左表达式以右表达式开头
        case beginsWith = 8
        /// 左表达式以右表达式结束
        case endsWith = 9
        
        /// 左表达式为右表达式的集合元素
        case `in` = 10 // rhs contains lhs returns true
        
        /// 通过自定义的方法验证
        case customSelector = 11
        
        /// 左表达式包含右表达式
        @available(iOS 3.0, *)
        case contains = 99 // lhs contains rhs returns true
        
        /// 左表达式在右表达式的范围中 "left BETWEEN { 0 , 33 }"
        @available(iOS 3.0, *)
        case between = 100
    }
}
